package com.example.controller;

import com.example.pojo.Emp;
import com.example.pojo.LoginInfo;
import com.example.pojo.Result;
import com.example.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Sun
 * @Date: 2025/9/23 - 09 - 23 - 10:28
 * @Description: com.example.controller
 */
@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmpService empService;
    @PostMapping("/login")
    public Result login(@RequestBody Emp emp){
        log.info("用户登录，用户名：{}",emp.getUsername());
       LoginInfo logininfo = empService.login(emp);
       if(logininfo!=null){
        return Result.success(logininfo);
       }return Result.error("用户名或密码错误");
    }
}
